/* 根据剧本ID 获取 对应的角色  */

import { http } from "@/utils/http";

const getPcToken = () => {
  return localStorage.getItem("pcToken");
};
const baseProxy = import.meta.env.VITE_BASEPROXY;

/** 根据剧本ID 获取对应的角色角色 */
export const getCharacterById = (id: number) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgRole/queryRoleList`,
    {
      data: {
        scriptId: id
      }
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};

/** 更新角色 */
export const updateCharacter = (item: any) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgRole/updateRole`,
    {
      data: item
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};
/** 删除角色 */
export const delCharacter = (id: number) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgRole/deleteRole`,
    {
      data: {
        id: id
      }
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};
/** 新建角色 */
export const addCharacter = (item: object) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgRole/createRole`,
    {
      data: item
    },
    {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};
